package com.xbongbong.paas.service.stage;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.OpportunityStageAddDTO;
import com.xbongbong.paas.pojo.dto.StageDefaultAndLinkOptionSaveDTO;
import com.xbongbong.paas.pojo.dto.StageProcessAddDTO;
import com.xbongbong.paas.pojo.dto.StageProcessArchiveDTO;
import com.xbongbong.paas.pojo.dto.StageProcessDefaultVersionSetDTO;
import com.xbongbong.paas.pojo.dto.StageProcessDeleteDTO;
import com.xbongbong.paas.pojo.dto.StageProcessEnableDTO;
import com.xbongbong.paas.pojo.dto.StageProcessGetDTO;
import com.xbongbong.paas.pojo.dto.StageProcessGetExceptDTO;
import com.xbongbong.paas.pojo.dto.StageProcessSaveDTO;
import com.xbongbong.paas.pojo.dto.StageProcessSortDTO;
import com.xbongbong.paas.pojo.dto.StageProcessVersionDTO;
import com.xbongbong.paas.pojo.dto.StageRatioAttrNameGetDTO;
import com.xbongbong.paas.pojo.dto.StageRatioAttrNameSetDTO;
import com.xbongbong.paas.pojo.vo.StageProcessArchiveVO;
import com.xbongbong.paas.pojo.vo.StageProcessEnableVO;
import com.xbongbong.paas.pojo.vo.StageProcessGetExceptVO;
import com.xbongbong.paas.pojo.vo.StageProcessGetVO;
import com.xbongbong.paas.pojo.vo.StageProcessVersionVO;
import com.xbongbong.paas.pojo.vo.StageRatioAttrNameGetVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.BaseVO;

import java.util.List;

/**
 * 阶段流程service
 * @author 李少杰
 * @version v1.0.0
 * @date 2021/11/18 14:42
 */
public interface StageProcessService {

    /**
     * 流程版本
     * @param stageProcessVersionDTO
     * @return
     * @throws XbbException
     */
    StageProcessVersionVO stageProcessVersion(StageProcessVersionDTO stageProcessVersionDTO) throws XbbException;

    /**
     * 当前启用的流程版本
     * @param stageProcessVersionDTO
     * @return
     * @throws XbbException
     */
    StageProcessVersionVO currentEnableVersion(StageProcessVersionDTO stageProcessVersionDTO) throws XbbException;

    /**
     * 设置阶段的默认值和选项关联
     *
     * @return
     * @throws XbbException
     */
    BaseVO setStageDefaultAndLinkOption(StageDefaultAndLinkOptionSaveDTO stageDefaultAndLinkOptionSaveDTO) throws XbbException;

    /**
     * 获取流程
     * @param stageProcessGetDTO
     * @return ProcessGetVO
     * @throws XbbException
     */
    StageProcessGetVO get(StageProcessGetDTO stageProcessGetDTO) throws XbbException;

    /**
     * 排序 设置优先级
     *
     * @param stageProcessSortDTO
     * @return
     * @throws XbbException
     */
    BaseVO sort(StageProcessSortDTO stageProcessSortDTO) throws XbbException;

    /**
     * 阶段筛选（级联筛选：版本 + 阶段，默认为当前版本 【不剔除任何】） - bi统计使用
     * @param stageProcessGetExceptDTO
     * @return com.xbongbong.paas.pojo.vo.stageProcessGetExceptDTO
     * @throws XbbException
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    StageProcessGetExceptVO getAll(StageProcessGetExceptDTO stageProcessGetExceptDTO) throws XbbException;

    /**
     * 【机会专用】阶段筛选（级联筛选：版本 + 阶段，默认为当前版本 【剔除取消】） - 新增类机会统计使用
     * @param stageProcessGetExceptDTO
     * @return com.xbongbong.paas.pojo.vo.stageProcessGetExceptDTO
     * @throws XbbException
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    StageProcessGetExceptVO getExceptCancel(StageProcessGetExceptDTO stageProcessGetExceptDTO) throws XbbException;

    /**
     * 【机会专用】阶段筛选（级联筛选：版本 + 阶段，默认为当前版本 【剔除失败、取消】） - 预计类机会统计使用
     * @param stageProcessGetExceptDTO
     * @return com.xbongbong.paas.pojo.vo.stageProcessGetExceptDTO
     * @throws XbbException
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    StageProcessGetExceptVO getExceptLoseCancel(StageProcessGetExceptDTO stageProcessGetExceptDTO) throws XbbException;

    /**
     * 流程启用/暂停
     * @param stageProcessEnableDTO
     * @return ProcessEnableVO
     * @throws XbbException
     */
    StageProcessEnableVO enable(StageProcessEnableDTO stageProcessEnableDTO) throws XbbException;

    /**
     * 归档状态变更
     * @param stageProcessArchiveDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO archive(StageProcessArchiveDTO stageProcessArchiveDTO) throws XbbException;

    /**
     * 取消归档状态
     * @param stageProcessArchiveDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO cancelArchive(StageProcessArchiveDTO stageProcessArchiveDTO) throws XbbException;

    /**
     * 阶段流程删除
     * @param stageProcessDeleteDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO delete(StageProcessDeleteDTO stageProcessDeleteDTO) throws XbbException;

    /**
     * 阶段流程新建
     * @param stageProcessAddDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO add(StageProcessAddDTO stageProcessAddDTO) throws XbbException;

    /**
     * 阶段流程复制
     * @param stageProcessAddDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO copy(StageProcessAddDTO stageProcessAddDTO) throws XbbException;

    /**
     * 阶段流程保存
     * @param stageProcessSaveDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO save(StageProcessSaveDTO stageProcessSaveDTO) throws XbbException;

    /**
     * 设置阶段比例字段名
     * @param stageRatioAttrNameSetDTO
     * @return
     * @throws XbbException
     */
    BaseVO updateStageRatioAttrName(StageRatioAttrNameSetDTO stageRatioAttrNameSetDTO) throws XbbException;

    /**
     * 获取阶段比例字段名
     * @param stageRatioAttrNameGetDTO
     * @return
     * @throws XbbException
     */
    StageRatioAttrNameGetVO getStageRatioAttrName(StageRatioAttrNameGetDTO stageRatioAttrNameGetDTO) throws XbbException;

    /**
     * 机会生成新版本
     * @param opportunityStageAddDTO
     * @return
     * @throws XbbException
     */
    StageProcessArchiveVO opportunityStageAdd(OpportunityStageAddDTO opportunityStageAddDTO) throws XbbException;

    /**
     * 表单解释保存之前，校验多版本启用时设置的默认版本是否合法
     *
     * @param explains
     * @param corpid
     * @param formId
     * @throws XbbException
     */
    void validateMultiVersionDefaultStageProcess(List<FieldAttrEntity> explains, String corpid, Long formId) throws XbbException;

}
